<?php
/*
 *  This file is part of Urd.
 *
 *  Urd is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *  Urd is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. See the file "COPYING". If it does not
 *  exist, see <http://www.gnu.org/licenses/>.
 *
 * $LastChangedDate: 2008-07-11 09:38:52 +0200 (Fri, 11 Jul 2008) $
 * $Rev: 1286 $
 * $Author: gavinspearhead $
 * $Id: install.1.inc.php 1286 2008-07-11 07:38:52Z gavinspearhead $
 */


// This is an include-only file:
if (!defined('ORIGINAL_PAGE')) die("This file cannot be accessed directly.");

// Check for PHP settings
$OUT .= '<tr><td colspan="2" class="install1">PHP Settings</td></tr>' . "\n";

$OUT .= '<tr><td class="install2">PHP version &ge; 5.1.2</td>';
$OUT .= GenRetVal(CheckPHPVersion(), $rv_php);
if (!$rv_php) $OUT .= ShowHelp("Please upgrade to the latest version of PHP, e.g. 'apt-get update; apt-get upgrade' as root.");

$OUT .= '<tr><td class="install2">PHP allows "exec"</td>';
$OUT .= GenRetVal(CheckPHPExec(), $rv_php2);
if (!$rv_php2) $OUT .= ShowHelp("Please edit your php.ini to allow use of the exec command.");

$OUT .= '<tr><td class="install2">PHP command line interface installed</td>';
$OUT .= GenRetVal(CheckPHPCLI($_SESSION['php_path']), $rv_php2b);
if (!$rv_php2b) $OUT .= ShowHelp("Please install the PHP command line interface, e.g. 'apt-get install php5-cli' as root.");

$OUT .= '<tr><td class="install2">PHP has Safe Mode disabled</td>';
$OUT .= GenRetVal(CheckPHPSafeMode(), $rv_php3);
if (!$rv_php3) $OUT .= ShowHelp("Safe Mode is really outdated. You can disable it in the php.ini file.");

$OUT .= '<tr><td class="install2">PHP has Register Globals disabled</td>';
$OUT .= GenRetVal(CheckPHPRegGlobals(), $rv_php4);
if (!$rv_php4) $OUT .= ShowHelp("Register Globals is the biggest security hole ever. It also breaks URD in places, so you'll have to disable it in your php.ini.");

$OUT .= '<tr><td class="install2">PHP has access to Smarty</td>';
$OUT .= GenRetVal(CheckPHPSmarty(), $rv_php5);
if (!$rv_php5) $OUT .= ShowHelp("URD needs the Smarty template system. Try 'apt-get install smarty' as root to install it. Also check /etc/php5/apache2/php.ini (on Ubuntu) or /etc/php.ini (on CentOS) if include_path is enabled ");

$OUT .= '<tr><td class="install2">PHP module pcntl available</td>';
$OUT .= GenRetVal(CheckPHPpcntl($_SESSION['php_path']), $rv_php6);
if (!$rv_php6) $OUT .= ShowHelp("The pcntl module is required by the URD daemon. Note that there currently is no Windows pcntl support. This and the other PHP modules should automatically be installed when you 'apt-get install php5-cli'.");

$OUT .= '<tr><td class="install2">PHP module sockets available</td>';
$OUT .= GenRetVal(CheckPHPsockets($_SESSION['php_path']), $rv_php7);
if (!$rv_php7) $OUT .= ShowHelp("The sockets module is required by the URD daemon.");

$OUT .= '<tr><td class="install2">PHP module posix available</td>';
$OUT .= GenRetVal(CheckPHPposix($_SESSION['php_path']), $rv_php8);
if (!$rv_php8) $OUT .= ShowHelp("The posix module is required by the URD daemon.");

$OUT .= '<tr><td class="install2">PHP module OpenSSL available</td>';
$OUT .= GenRetVal(CheckPHPOpenSSL($_SESSION['php_path']), $rv_php8b);
if (!$rv_php8b) $OUT .= ShowHelp("The openssl module is optional, needed for SSL connections to news servers.");

$OUT .= '<tr><td class="install2">PHP module XMLRPC available</td>';
$OUT .= GenRetVal(CheckPHPXMLRPC(), $rv_phpxmlrpc);
if (!$rv_phpxmlrpc) $OUT .= ShowHelp("The XMLRPC module is optional but required for up/downloading set information. Try: sudo apt-get install php5-xmlrpc");

$OUT .= '<tr><td class="install2">PHP module XMLreader/writer available</td>';
$OUT .= GenRetVal(CheckPHPXMLRW(), $rv_phpxmlrW);
if (!$rv_phpxmlrw) $OUT .= ShowHelp("The XMLreader and XMLwriter module is optional but required for backing-up URD configuration. Try: sudo pecl install XMLReader && sudo pecl install XMLwriter");

$OUT .= '<tr><td class="install2">PHP module CURL available</td>';
$OUT .= GenRetVal(CheckPHPCURL(), $rv_phpcurl);
if (!$rv_phpcurl) $OUT .= ShowHelp("The CURL module is required by the URD daemon. Try: sudo apt-get install php5-curl");

$OUT .= '<tr><td class="install2">PHP module GMP available</td>';
$OUT .= GenRetVal(CheckPHPGMP(), $rv_phpgmp);
if (!$rv_phpgmp) $OUT .= ShowHelp("The GMP module is required by the URD daemon. Try: sudo apt-get install php5-gmp");

$OUT .= '<tr><td class="install2">PHP module SPL available</td>';
$OUT .= GenRetVal(CheckPHPSPL($_SESSION['php_path']), $rv_php9);
if (!$rv_php9) $OUT .= ShowHelp("The SPL module is required by the URD daemon.");

$OUT .= '<tr><td class="install2">PHP memory limit &ge; 128 MB</td>';
$OUT .= GenRetVal(CheckPHPMemory($_SESSION['php_path']), $rv_php10);
if (!$rv_php10) $OUT .= ShowHelp("The current PHP memory limit (for the command line interface) is too low, please raise it to 128 MB in the (cli!) php.ini file - /etc/php5/cli/php.ini (on Ubuntu).");

if ($rv_php && $rv_php2 && $rv_php3 && $rv_php4 && $rv_php5 && $rv_php6 && $rv_php7 && $rv_php8 && $rv_php9 && $rv_php10 && $rv_phpcurl && $rv_phpgmp) {
	write_smarty_config($_SESSION['smarty']);
	$OUT .= '<tr colspan="2"><td><a onclick="LoadPage(2);">'.$continuepic.'</a></td></tr>';
} else {
	$OUT .= 'Not all requirements are met, please fix.<br/>';
	$OUT .= '<tr colspan="2"><td><a onclick="LoadPage(1);">'.$refreshpic.'</a></td></tr>';
}
?>
